package runtime;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.google.gson.Gson;

import data.dynamodbfunctions.Persistence_Helper_PubForum;
import data.dynamodbfunctions.Persistence_Helper_PubThread;
import data.dynamodbfunctions.Persistence_Helper_PubEntry;
import data.exceptions.Dynamo_DB_Functions_Exception;
import data.objects.PubEntry;
import data.objects.PubForum;
import data.objects.PubThread;
import data.objects.Select_Condition;

public class Test_Exceptions {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Gson gson = new Gson();
		
		
		Set<String> set=new HashSet<String>();
		set.add("Alex");
		set.add("Markus");
		set.add("Johannnes");
		
		
		//Entry
		System.out.println("Entry");
		Select_Condition condition1=new Select_Condition("Admin","=","Alexander");
		Select_Condition condition2=new Select_Condition("Text","=","Text(1,1)");
		List<Select_Condition> conditionlist=new ArrayList<Select_Condition>();
		conditionlist.add(condition1);
		conditionlist.add(condition2);
		List<PubEntry> result=null;
		try {
			result = Persistence_Helper_PubEntry.getInstance().readwithAttributes("0", conditionlist);
		} catch (Dynamo_DB_Functions_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (PubEntry c : result) {
            System.out.println(gson.toJson(c));
        }
		
		
		
		System.out.println("");
		System.out.println("Forum");
		Select_Condition condition11=new Select_Condition("Admin","=","Markus");
		Select_Condition condition21=new Select_Condition("Beschreibung","=","Test");
		List<Select_Condition> conditionlist1=new ArrayList<Select_Condition>();
		conditionlist1.add(condition11);
		conditionlist1.add(condition21);
		List<PubForum> result1=null;
		try {
			result1 = Persistence_Helper_PubForum.getInstance().readwithAttributes("1", conditionlist1);
		} catch (Dynamo_DB_Functions_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (PubForum c : result1) {
            System.out.println(gson.toJson(c));
        }
		
		System.out.println("");
		System.out.println("Thread");
		Select_Condition condition12=new Select_Condition("Admin","=","Markus");
		Select_Condition condition22=new Select_Condition("Name","=","Thread0");
		List<Select_Condition> conditionlist2=new ArrayList<Select_Condition>();
		conditionlist2.add(condition12);
		conditionlist2.add(condition22);
		List<PubThread> result2=null;
		try {
			result2 = Persistence_Helper_PubThread.getInstance().readwithAttributes("1", conditionlist2);
		} catch (Dynamo_DB_Functions_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (PubThread c : result2) {
            System.out.println(gson.toJson(c));
        }

//		System.out.println("Create a Forum");
//				
//		Forum testforum=new Forum("Tenant_1","Alex",set,"Test","Testforum");
//		forumfunctions.create(testforum);
//		try {
//			System.out.println(gson.toJson(forumfunctions.read("Tenant_1", testforum.getForum_id())));
//			System.out.println(gson.toJson(forumfunctions.read("Tenant_1", "xxx")));
//			testforum.setName("Neuer Name");
//			forumfunctions.update(testforum);
//			System.out.println(gson.toJson(forumfunctions.read("Tenant_1", testforum.getForum_id())));
//			testforum.setForum_id("xxxxxx");
//			forumfunctions.update(testforum);
//			Persistence_Helper_PubForum.getInstance().delete("Tenant_3", "6f14115d-f165-4ff5-9c96-eeb51bfcd67a");
//		} catch (Dynamo_DB_Functions_Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}

	}

}
